package com.class1group3.demo.controller;

import com.class1group3.demo.HiveService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/hive")
public class HiveController {

    @Autowired
    private HiveService hiveService;

    @GetMapping("/query")
    public List<Map<String, Object>> queryHive(@RequestParam String sql) {
        return hiveService.executeQuery(sql);
    }

    @GetMapping("/tables")
    public List<Map<String, Object>> getTables() {
        return hiveService.executeQuery("SHOW TABLES");
    }
}